package com.strongwell.awe.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;

import com.strongwell.awe.dao.CmsLinkDao;
import com.strongwell.awe.model.CmsLinkEntity;
import com.strongwell.awe.service.CmsLinkService;



@Service("cmsLinkServiceImpl")
public class CmsLinkServiceImpl implements CmsLinkService {
	@Autowired
	private CmsLinkDao cmsLinkDao;
	
	@Override
	public CmsLinkEntity queryObject(Long id){
		return cmsLinkDao.queryObject(id);
	}
	
	@Override
	public List<CmsLinkEntity> queryList(Map<String, Object> map){
		return cmsLinkDao.queryList(map);
	}
	
	@Override
	public int queryTotal(Map<String, Object> map){
		return cmsLinkDao.queryTotal(map);
	}
	

	
	@Override
	public int delete(Long id){
		return cmsLinkDao.delete(id);
	}
	
	@Override
	public int deleteBatch(Long[] ids){
		return cmsLinkDao.deleteBatch(ids);
	}

    @Override
    public void save(CmsLinkEntity cmslink){
        Date date=new Date();
        cmslink.setCreateTime(date);
			cmsLinkDao.save(cmslink);
    }

    @Override
    public int update(CmsLinkEntity cmslink){
        Date date=new Date();
        cmslink.setUpdateTime(date);
        return cmsLinkDao.update(cmslink);
    }

    public int delById(Long id){
        Date date=new Date();
			CmsLinkEntity cmslink= new CmsLinkEntity();
        cmslink.setId(id);
        cmslink.setDeleteTime(date);
        return cmsLinkDao.update(cmslink);
    }

    public int delPatch(String  cmslinkstr){
        String[] strs = cmslinkstr.split(",");
        if(strs!=null&&strs.length>0){
            for (String str : strs) {
                delById(Long.parseLong(str));
            }
        }
        return 0;
    }

    public CmsLinkEntity queryName(String name){
        return cmsLinkDao.queryName(name);
    }
}
